package com.zzyl.config;


import com.aliyun.iot20180120.Client;
import com.aliyun.teaopenapi.models.Config;
import com.zzyl.properties.AliIOTConfigProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class AliClientConfig {
    @Autowired
    private AliIOTConfigProperties aliIOTConfigProperties;

    @Bean
    public Client client() throws Exception {
        Config config = new Config();
        config.accessKeyId = aliIOTConfigProperties.getAccessKeyId();
        config.accessKeySecret = aliIOTConfigProperties.getAccessKeySecret();
        config.regionId = aliIOTConfigProperties.getRegionId();
        Client client = new Client(config);
        return client;
    }
}
